﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreRay
{
    public class StatisticsItemPercent : StatisticsItem
    {
        public StatisticsItemPercent(string name) : this(name, 0, 0)
        {

        }

        public StatisticsItemPercent(string name, float value, float total) : base(name)
        {
            this.Value = value;
            this.Total = total;
        }

        public float Value
        {
            get;
            set;
        }

        public float Total
        {
            get;
            set;
        }

        public override float ComputeValue()
        {
            if (this.Total == 0.0f)
            {
                throw new InvalidOperationException("The total must be different from 0.");
            }

            return (this.Value / this.Total) * 100.0f;
        }
    }
}
